package com.ffcs.web.utils;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class XingqiUtil {

	public static String getWeekOfDate(Date date) {      
	    String[] weekOfDays = {"7", "1", "2", "3", "4", "5", "6"};        
	    Calendar calendar = Calendar.getInstance();      
	    if(date != null){        
	         calendar.setTime(date);      
	    }        
	    int w = calendar.get(Calendar.DAY_OF_WEEK) - 1;      
	    if (w < 0){        
	        w = 0;      
	    }      
	    return weekOfDays[w];    

	}
	
	public static String getHours() {      
		Date d = new Date();
		int hours = d.getHours();
		return hours+"";

	}
	public static String getDay(Date date) {      
		SimpleDateFormat sdf=new SimpleDateFormat("MM-dd");
		return sdf.format(date);
	}
	
	public static void main(String[] args) {
		System.out.println(XingqiUtil.getDayList(6).get(0));
	}
	
	public static Date getDate(int i) {      
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		calendar.add(Calendar.DATE, +i);
		Date date=calendar.getTime();
		return date;
	}
	public static List<String> getDayList(int bookXingqi) {
		int xingqi=Integer.parseInt(getWeekOfDate(new Date()));
		SimpleDateFormat sdf=new SimpleDateFormat("MM月dd日");
		String d1="";
		String d2="";
		String d3="";
		String d4="";
		String d5="";
		String d6="";
		String d7="";
		if(xingqi==bookXingqi){
			d1=sdf.format(new Date());
			d2=sdf.format(getDate(1));
			d3=sdf.format(getDate(2));
			d4=sdf.format(getDate(3));
			d5=sdf.format(getDate(4));
			d6=sdf.format(getDate(5));
			d7=sdf.format(getDate(6));
		}else if(xingqi==(bookXingqi+1)){
			d1=sdf.format(getDate(6));
			d2=sdf.format(new Date());
			d3=sdf.format(getDate(1));
			d4=sdf.format(getDate(2));
			d5=sdf.format(getDate(3));
			d6=sdf.format(getDate(4));
			d7=sdf.format(getDate(5));
		}else if(xingqi==(bookXingqi+2)){
			d1=sdf.format(getDate(5));
			d2=sdf.format(getDate(6));
			d3=sdf.format(new Date());
			d4=sdf.format(getDate(1));
			d5=sdf.format(getDate(2));
			d6=sdf.format(getDate(3));
			d7=sdf.format(getDate(4));
		}else if(xingqi==(bookXingqi+3)){
			d1=sdf.format(getDate(4));
			d2=sdf.format(getDate(5));
			d3=sdf.format(getDate(6));
			d4=sdf.format(new Date());
			d5=sdf.format(getDate(1));
			d6=sdf.format(getDate(2));
			d7=sdf.format(getDate(3));
		}else if(xingqi==(bookXingqi+4)){
			d1=sdf.format(getDate(3));
			d2=sdf.format(getDate(4));
			d3=sdf.format(getDate(5));
			d4=sdf.format(getDate(6));
			d5=sdf.format(new Date());
			d6=sdf.format(getDate(1));
			d7=sdf.format(getDate(2));
		}else if(xingqi==(bookXingqi+5)){
			d1=sdf.format(getDate(2));
			d2=sdf.format(getDate(3));
			d3=sdf.format(getDate(4));
			d4=sdf.format(getDate(5));
			d5=sdf.format(getDate(6));
			d6=sdf.format(new Date());
			d7=sdf.format(getDate(1));
		}else if(xingqi==(bookXingqi+6)){
			d1=sdf.format(getDate(1));
			d2=sdf.format(getDate(2));
			d3=sdf.format(getDate(3));
			d4=sdf.format(getDate(4));
			d5=sdf.format(getDate(5));
			d6=sdf.format(getDate(6));
			d7=sdf.format(new Date());
		}else if(xingqi==(bookXingqi-1)){
			d1=sdf.format(getDate(1));
			d2=sdf.format(getDate(2));
			d3=sdf.format(getDate(3));
			d4=sdf.format(getDate(4));
			d5=sdf.format(getDate(5));
			d6=sdf.format(getDate(6));
			d7=sdf.format(new Date());
		}else if(xingqi==(bookXingqi-2)){
			d1=sdf.format(getDate(2));
			d2=sdf.format(getDate(3));
			d3=sdf.format(getDate(4));
			d4=sdf.format(getDate(5));
			d5=sdf.format(getDate(6));
			d6=sdf.format(new Date());
			d7=sdf.format(getDate(1));
		}else if(xingqi==(bookXingqi-3)){
			d1=sdf.format(getDate(3));
			d2=sdf.format(getDate(4));
			d3=sdf.format(getDate(5));
			d4=sdf.format(getDate(6));
			d5=sdf.format(new Date());
			d6=sdf.format(getDate(1));
			d7=sdf.format(getDate(2));
		}else if(xingqi==(bookXingqi-4)){
			d1=sdf.format(getDate(4));
			d2=sdf.format(getDate(5));
			d3=sdf.format(getDate(6));
			d4=sdf.format(new Date());
			d5=sdf.format(getDate(1));
			d6=sdf.format(getDate(2));
			d7=sdf.format(getDate(3));
		}else if(xingqi==(bookXingqi-5)){
			d1=sdf.format(getDate(5));
			d2=sdf.format(getDate(6));
			d3=sdf.format(new Date());
			d4=sdf.format(getDate(1));
			d5=sdf.format(getDate(2));
			d6=sdf.format(getDate(3));
			d7=sdf.format(getDate(4));
		}else if(xingqi==(bookXingqi-6)){
			d1=sdf.format(getDate(6));
			d2=sdf.format(new Date());
			d3=sdf.format(getDate(1));
			d4=sdf.format(getDate(2));
			d5=sdf.format(getDate(3));
			d6=sdf.format(getDate(4));
			d7=sdf.format(getDate(5));
		}else{
			d1=sdf.format(new Date());
			d2=sdf.format(getDate(1));
			d3=sdf.format(getDate(2));
			d4=sdf.format(getDate(3));
			d5=sdf.format(getDate(4));
			d6=sdf.format(getDate(5));
			d7=sdf.format(getDate(6));
		}
		List<String> list=new ArrayList<String>();
		list.add(d1);
		list.add(d2);
		list.add(d3);
		list.add(d4);
		list.add(d5);
		list.add(d6);
		list.add(d7);
		return list;
	}
}
